﻿using DevExpress.Utils.Win;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Popup;
using DevExpress.XtraGrid.Demos.util;
using DevExpress.XtraGrid.Editors;
using DevExpress.XtraLayout;
using DiaoPaiDaYin;
using DXApplicationTangche.DTO;
using DXApplicationTangche.DTO.坚山;
using DXApplicationTangche.service;
using DXApplicationTangche.service.redis_service;
using DXApplicationTangche.UC.款式异常;
using DXApplicationTangche.UC.款式管理.service;
using DXApplicationTangche.UC.设计点;
using DXApplicationTangche.UC.销售记录.service;
using DXApplicationTangche.UC.门店下单.form;
using DXApplicationTangche.UC.门店下单.下单;
using DXApplicationTangche.Utils;
using mendian;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DXApplicationTangche.UC.坚山
{
    public partial class Frm坚山创建款式 : DevExpress.XtraBars.Ribbon.RibbonForm
    {
        private String 版型名称 { get; set; }
        private String 款式类别 { get; set; }
        private String 制作工艺 { get; set; }
        private String 款式 { get; set; }
        private Frm坚山订单创建 frm;
        public DTO坚山款式 dto坚山款式 { get; set; }
        public 门店下单选款式Model model = new 门店下单选款式Model();
        private XtraUserControlC设计点 XtraUserControlC设计点;
        private List<SizeFitKashiyamaDTO> sizeFitKashiyamaDTOS = new List<SizeFitKashiyamaDTO>();
        public Frm坚山创建款式(Frm坚山订单创建 frm)
        {
            InitializeComponent();
            this.frm = frm;
            //this.dto坚山款式 = FunctionHelper.JsonDeserialization<DTO坚山款式>(RestCall.httpGetMethod(URL.接口url + "/kashiyamaUS/getKashiyamaCacheInfo"));
            this.dto坚山款式 = 坚山数据Service.getDTO坚山款式();
            this.searchLookUpEdit款式.Properties.DataSource = this.dto坚山款式.DTO款式s;
            this.searchLookUpEdit款式类别.Properties.DataSource = this.dto坚山款式.DTO款式类别s;
            this.searchLookUpEdit版型.Properties.DataSource = this.dto坚山款式.DTO版型s;
            this.searchLookUpEdit面料.Properties.DataSource = this.dto坚山款式.DTO面料s;
            this.searchLookUpEdit制作工艺.Properties.DataSource = this.dto坚山款式.DTO制作工艺s;
        }

        #region 选择面料
        /// <summary>
        /// 绑定清空事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void searchLookUpEdit面料_Popup(object sender, EventArgs e)
        {
            //得到当前SearchLookUpEdit弹出窗体
            PopupSearchLookUpEditForm form = (sender as IPopupControl).PopupWindow as PopupSearchLookUpEditForm;
            SearchEditLookUpPopup popup = form.Controls.OfType<SearchEditLookUpPopup>().FirstOrDefault();
            LayoutControl layout = popup.Controls.OfType<LayoutControl>().FirstOrDefault();
            //如果窗体内空间没有确认按钮，则自定义确认simplebutton，取消simplebutton，选中结果label
            if (layout.Controls.OfType<Control>().Where(ct => ct.Name == "btOK").FirstOrDefault() == null)
            {
                //得到空的空间
                EmptySpaceItem a = layout.Items.Where(it => it.TypeName == "EmptySpaceItem").FirstOrDefault() as EmptySpaceItem;

                //得到取消按钮，重写点击事件
                Control clearBtn = layout.Controls.OfType<Control>().Where(ct => ct.Name == "btClear").FirstOrDefault();
                LayoutControlItem clearLCI = (LayoutControlItem)layout.GetItemByControl(clearBtn);
                clearBtn.Click += clearBtn_Click;

                //添加一个simplebutton控件(确认按钮)
                LayoutControlItem myLCI = (LayoutControlItem)clearLCI.Owner.CreateLayoutItem(clearLCI.Parent);
                myLCI.TextVisible = false;
            }
        }
        /// <summary>
        /// 点击选择后的行为
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void searchLookUpEdit面料View_Click(object sender, EventArgs e)
        {
            var a = this.searchLookUpEdit面料.Properties.View.GetSelectedRows();
            foreach (int rowHandle in a)
            {
                //Frm面料选择.mianliaocd = this.searchLookUpEdit面料.Properties.View.GetRowCellValue(rowHandle, "Code").ToString();
                Frm面料选择.mianliaoid= this.searchLookUpEdit面料.Properties.View.GetRowCellValue(rowHandle, "ID").ToString();
                Frm面料选择.mianliao = this.searchLookUpEdit面料.Properties.View.GetRowCellValue(rowHandle, "Name").ToString();
                this.model.Dto定制下单.SYTLE_FABRIC_ID = this.searchLookUpEdit面料.Properties.View.GetRowCellValue(rowHandle, "ID").ToString();
                Frm面料选择.mianliaocd = this.searchLookUpEdit面料.Properties.View.GetRowCellValue(rowHandle, "Code").ToString();
                this.model.Dto定制下单.materialCode = Frm面料选择.mianliaocd;
                String MLpicurl = RestCall.httpGetMethod(URL.接口url + "/image/getImagePath?materialCode=" + Frm面料选择.mianliaocd);
                if (String.IsNullOrWhiteSpace(MLpicurl) || MLpicurl.Contains("no"))
                {
                    this.pictureBox面料图片.Image = DXApplicationTangche.Properties.Resources.SSHIRT;
                }
                else
                {
                    this.pictureBox面料图片.LoadAsync(URL.图片url + URL.面料图片路径 + MLpicurl);
                }
            }
        }

        /// <summary>
        /// 清除按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void clearBtn_Click(object sender, EventArgs e)
        {
            this.searchLookUpEdit面料.ToolTip = null;
            searchLookUpEdit面料.EditValue = null;
        }
        /// <summary>
        /// 选完之后的显示
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void searchLookUpEdit面料_CustomDisplayText(object sender, DevExpress.XtraEditors.Controls.CustomDisplayTextEventArgs e)
        {
            if (null != e.Value)
                e.DisplayText = Frm面料选择.mianliaocd+":"+Frm面料选择.mianliao;
        }
        #endregion

        #region 选择版型
        /// <summary>
        /// 绑定清空事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void searchLookUpEdit版型_Popup(object sender, EventArgs e)
        {
            //得到当前SearchLookUpEdit弹出窗体
            PopupSearchLookUpEditForm form = (sender as IPopupControl).PopupWindow as PopupSearchLookUpEditForm;
            SearchEditLookUpPopup popup = form.Controls.OfType<SearchEditLookUpPopup>().FirstOrDefault();
            LayoutControl layout = popup.Controls.OfType<LayoutControl>().FirstOrDefault();
            //如果窗体内空间没有确认按钮，则自定义确认simplebutton，取消simplebutton，选中结果label
            if (layout.Controls.OfType<Control>().Where(ct => ct.Name == "btOK").FirstOrDefault() == null)
            {
                //得到空的空间
                EmptySpaceItem a = layout.Items.Where(it => it.TypeName == "EmptySpaceItem").FirstOrDefault() as EmptySpaceItem;

                //得到取消按钮，重写点击事件
                Control clearBtn = layout.Controls.OfType<Control>().Where(ct => ct.Name == "btClear").FirstOrDefault();
                LayoutControlItem clearLCI = (LayoutControlItem)layout.GetItemByControl(clearBtn);
                clearBtn.Click += clearBtn版型_Click;

                //添加一个simplebutton控件(确认按钮)
                LayoutControlItem myLCI = (LayoutControlItem)clearLCI.Owner.CreateLayoutItem(clearLCI.Parent);
                myLCI.TextVisible = false;
            }
        }
        /// <summary>
        /// 点击选择后的行为
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void searchLookUpEdit版型View_Click(object sender, EventArgs e)
        {
            var a = this.searchLookUpEdit版型.Properties.View.GetSelectedRows();
            foreach (int rowHandle in a)
            {
                this.版型名称 = this.searchLookUpEdit版型.Properties.View.GetRowCellValue(rowHandle, "Name").ToString();
                this.model.Dto定制下单.STYLE_FIT_CD = this.searchLookUpEdit版型.Properties.View.GetRowCellValue(rowHandle, "ID").ToString() + "-" + this.searchLookUpEdit版型.Properties.View.GetRowCellValue(rowHandle, "Code").ToString();
                
                //this.SYTLE_FABRIC_ID = this.SYTLE_FABRIC_ID + this.searchLookUpEdit面料.Properties.View.GetRowCellValue(rowHandle, "MATERIAL_ID").ToString() + ",";
                //this.面料NA = this.面料NA + this.searchLookUpEdit面料.Properties.View.GetRowCellValue(rowHandle, "MATERIAL_NAME_CN").ToString() + ",";
                //this.dto无订单打印.materials_id //  no
                //    = this.searchLookUpEdit1.Properties.View.GetRowCellValue(rowHandle, "id").ToString();//id 是 Value Member
                //this.dto无订单打印.materials_cd //  no
                //    = this.searchLookUpEdit1.Properties.View.GetRowCellValue(rowHandle, "materialCode").ToString();//id 是 Value Member
                //this.dto无订单打印.materialComposition = this.searchLookUpEdit1.Properties.View.GetRowCellValue(rowHandle, "materialComposition").ToString();
                //this.dto无订单打印.materialNameCn = this.searchLookUpEdit1.Properties.View.GetRowCellValue(rowHandle, "materialNameCn").ToString();
            }
            //this.mianliaoid.Text = this.dto无订单打印.materials_id;
            //this.mianliaocd.Text = this.dto无订单打印.materials_cd;
            //this.chengfen.Text = this.dto无订单打印.materialComposition;
        }

        /// <summary>
        /// 清除按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void clearBtn版型_Click(object sender, EventArgs e)
        {
            this.searchLookUpEdit版型.ToolTip = null;
            searchLookUpEdit版型.EditValue = null;
        }
        /// <summary>
        /// 选完之后的显示
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void searchLookUpEdit版型_CustomDisplayText(object sender, DevExpress.XtraEditors.Controls.CustomDisplayTextEventArgs e)
        {
            if (null != e.Value)
                e.DisplayText = this.版型名称;
        }
        #endregion

        #region 选择款式类别
        /// <summary>
        /// 绑定清空事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void searchLookUpEdit款式类别_Popup(object sender, EventArgs e)
        {
            //得到当前SearchLookUpEdit弹出窗体
            PopupSearchLookUpEditForm form = (sender as IPopupControl).PopupWindow as PopupSearchLookUpEditForm;
            SearchEditLookUpPopup popup = form.Controls.OfType<SearchEditLookUpPopup>().FirstOrDefault();
            LayoutControl layout = popup.Controls.OfType<LayoutControl>().FirstOrDefault();
            //如果窗体内空间没有确认按钮，则自定义确认simplebutton，取消simplebutton，选中结果label
            if (layout.Controls.OfType<Control>().Where(ct => ct.Name == "btOK").FirstOrDefault() == null)
            {
                //得到空的空间
                EmptySpaceItem a = layout.Items.Where(it => it.TypeName == "EmptySpaceItem").FirstOrDefault() as EmptySpaceItem;

                //得到取消按钮，重写点击事件
                Control clearBtn = layout.Controls.OfType<Control>().Where(ct => ct.Name == "btClear").FirstOrDefault();
                LayoutControlItem clearLCI = (LayoutControlItem)layout.GetItemByControl(clearBtn);
                clearBtn.Click += clearBtn款式类别_Click;

                //添加一个simplebutton控件(确认按钮)
                LayoutControlItem myLCI = (LayoutControlItem)clearLCI.Owner.CreateLayoutItem(clearLCI.Parent);
                myLCI.TextVisible = false;
            }
        }
        /// <summary>
        /// 点击选择后的行为
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void searchLookUpEdit款式类别View_Click(object sender, EventArgs e)
        {
            var a = this.searchLookUpEdit款式类别.Properties.View.GetSelectedRows();
            foreach (int rowHandle in a)
            {
                this.款式类别= this.searchLookUpEdit款式类别.Properties.View.GetRowCellValue(rowHandle, "Name").ToString();
                this.model.Dto定制下单.STYLE_CATEGORY_CD = "STYLE_CATEGORY-" + this.searchLookUpEdit款式类别.Properties.View.GetRowCellValue(rowHandle, "ID").ToString();
                //this.SYTLE_FABRIC_ID = this.SYTLE_FABRIC_ID + this.searchLookUpEdit面料.Properties.View.GetRowCellValue(rowHandle, "MATERIAL_ID").ToString() + ",";
                //this.面料NA = this.面料NA + this.searchLookUpEdit面料.Properties.View.GetRowCellValue(rowHandle, "MATERIAL_NAME_CN").ToString() + ",";
                //this.dto无订单打印.materials_id //  no
                //    = this.searchLookUpEdit1.Properties.View.GetRowCellValue(rowHandle, "id").ToString();//id 是 Value Member
                //this.dto无订单打印.materials_cd //  no
                //    = this.searchLookUpEdit1.Properties.View.GetRowCellValue(rowHandle, "materialCode").ToString();//id 是 Value Member
                //this.dto无订单打印.materialComposition = this.searchLookUpEdit1.Properties.View.GetRowCellValue(rowHandle, "materialComposition").ToString();
                //this.dto无订单打印.materialNameCn = this.searchLookUpEdit1.Properties.View.GetRowCellValue(rowHandle, "materialNameCn").ToString();
            }
            //this.mianliaoid.Text = this.dto无订单打印.materials_id;
            //this.mianliaocd.Text = this.dto无订单打印.materials_cd;
            //this.chengfen.Text = this.dto无订单打印.materialComposition;
        }

        /// <summary>
        /// 清除按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void clearBtn款式类别_Click(object sender, EventArgs e)
        {
            this.searchLookUpEdit款式类别.ToolTip = null;
            searchLookUpEdit款式类别.EditValue = null;
        }
        /// <summary>
        /// 选完之后的显示
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void searchLookUpEdit款式类别_CustomDisplayText(object sender, DevExpress.XtraEditors.Controls.CustomDisplayTextEventArgs e)
        {
            if (null != e.Value)
                e.DisplayText = this.款式类别;
        }
        #endregion

        #region 选择款式
        /// <summary>
        /// 绑定清空事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void searchLookUpEdit款式_Popup(object sender, EventArgs e)
        {
            //得到当前SearchLookUpEdit弹出窗体
            PopupSearchLookUpEditForm form = (sender as IPopupControl).PopupWindow as PopupSearchLookUpEditForm;
            SearchEditLookUpPopup popup = form.Controls.OfType<SearchEditLookUpPopup>().FirstOrDefault();
            LayoutControl layout = popup.Controls.OfType<LayoutControl>().FirstOrDefault();
            //如果窗体内空间没有确认按钮，则自定义确认simplebutton，取消simplebutton，选中结果label
            if (layout.Controls.OfType<Control>().Where(ct => ct.Name == "btOK").FirstOrDefault() == null)
            {
                //得到空的空间
                EmptySpaceItem a = layout.Items.Where(it => it.TypeName == "EmptySpaceItem").FirstOrDefault() as EmptySpaceItem;

                //得到取消按钮，重写点击事件
                Control clearBtn = layout.Controls.OfType<Control>().Where(ct => ct.Name == "btClear").FirstOrDefault();
                LayoutControlItem clearLCI = (LayoutControlItem)layout.GetItemByControl(clearBtn);
                clearBtn.Click += clearBtn款式_Click;

                //添加一个simplebutton控件(确认按钮)
                LayoutControlItem myLCI = (LayoutControlItem)clearLCI.Owner.CreateLayoutItem(clearLCI.Parent);
                myLCI.TextVisible = false;
            }
        }
        /// <summary>
        /// 点击选择后的行为
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void searchLookUpEdit款式View_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
        {
            this.款式 = FunctionHelper.GetgridViewValue(this.searchLookUpEdit款式.Properties.View, e.RowHandle, "Name").ToString();
            this.model.Dto定制下单.Style_Id = FunctionHelper.GetgridViewValue(this.searchLookUpEdit款式.Properties.View, e.RowHandle, "ID").ToString();
            //  设计点：
            this.model.Dto定制下单.Dto设计点s.Clear();
            //  接口查询前的坚山别名替换
            String 款式别名 = this.款式.Replace(" ", "-KA ");
            this.XtraUserControlC设计点 = new XtraUserControlC设计点(款式别名);
            //  坚山款式查设计点
            if (this.XtraUserControlC设计点.Dto设计点s.Count <= 0)
            {
                this.XtraUserControlC设计点.build坚山(this.model.Dto定制下单.Style_Id);
            }
            this.model.Dto定制下单.Dto设计点s = this.XtraUserControlC设计点.Dto设计点s;
            this.initNavigationPage(this.XtraUserControlC设计点);
            //  坚山款式查设计点用接口没查到再用sql查询
            //if (this.model.Dto定制下单.Dto设计点s.Count <= 0)
            //{
            //    UC设计点 uc设计点 = new UC设计点(this.model.Dto定制下单.Dto设计点s, this.model.Dto定制下单.Style_Id, this.dto坚山款式);
            //    this.initNavigationPage(uc设计点);
            //}
            //  尺码及尺寸表用参数
            KashiyamaStyleSizeDTO kashiyama = 款式Service.getStyleInfoById(Convert.ToInt32(this.model.Dto定制下单.Style_Id));
            this.model.Dto定制下单
                .build选中款式(
                    kashiyama.styleInfoDto.sysStyleId.ToString(),//dr["SYS_STYLE_ID"].ToString(), 
                    kashiyama.styleInfoDto.styleCategoryCd,//dr["STYLE_CATEGORY_CD"].ToString(), 
                    kashiyama.styleInfoDto.styleFitCd,//dr["STYLE_FIT_CD"].ToString(), 
                    kashiyama.styleInfoDto.styleSizeGroupCd,//dr["STYLE_SIZE_GROUP_CD"].ToString(), 
                    "",
                    kashiyama.styleInfoDto.styleMakeType//dr["STYLE_MAKE_TYPE"].ToString()
                );//添加选中款式数据
            this.sizeFitKashiyamaDTOS = kashiyama.sizeFitKashiyamaDTOS;
            this.chicun01.Items.Clear();
            foreach (SizeFitKashiyamaDTO item in kashiyama.sizeFitKashiyamaDTOS)
            {
                this.chicun01.Items.Add(item.sizeCdShort);
            }
            //DataRow dr = SQLmtm.GetDataRow("SELECT * FROM s_style_p WHERE SYS_STYLE_ID='" + this.model.Dto定制下单.Style_Id + "'");
            //this.model.Dto定制下单.build选中款式(dr["SYS_STYLE_ID"].ToString(), dr["STYLE_CATEGORY_CD"].ToString(), dr["STYLE_FIT_CD"].ToString(), dr["STYLE_SIZE_GROUP_CD"].ToString(), "", dr["STYLE_MAKE_TYPE"].ToString());//添加选中款式数据
            //this.model.build款式全尺寸(this.model.Dto定制下单.Style_Id);
            //Frm定制下单修改尺寸.stylesizedt = StyleService.StyleCombobox(this.model.Dto定制下单.Style_Id);
            //this.chicun01.Items.Clear();
            //if (Frm定制下单修改尺寸.stylesizedt != null)
            //{
            //    foreach (DataRow ddr in Frm定制下单修改尺寸.stylesizedt.Rows)
            //    {
            //        this.chicun01.Items.Add(Convert.ToString(ddr["尺寸"]));
            //    }
            //}
        }
        /// <summary>
        /// 清除按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void clearBtn款式_Click(object sender, EventArgs e)
        {
            this.searchLookUpEdit款式.ToolTip = null;
            searchLookUpEdit款式.EditValue = null;
        }
        /// <summary>
        /// 选完之后的显示
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void searchLookUpEdit款式_CustomDisplayText(object sender, DevExpress.XtraEditors.Controls.CustomDisplayTextEventArgs e)
        {
            if (null != e.Value)
                e.DisplayText = this.款式;
        }
        #endregion

        #region 选择制作工艺
        /// <summary>
        /// 绑定清空事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void searchLookUpEdit制作工艺_Popup(object sender, EventArgs e)
        {
            //得到当前SearchLookUpEdit弹出窗体
            PopupSearchLookUpEditForm form = (sender as IPopupControl).PopupWindow as PopupSearchLookUpEditForm;
            SearchEditLookUpPopup popup = form.Controls.OfType<SearchEditLookUpPopup>().FirstOrDefault();
            LayoutControl layout = popup.Controls.OfType<LayoutControl>().FirstOrDefault();
            //如果窗体内空间没有确认按钮，则自定义确认simplebutton，取消simplebutton，选中结果label
            if (layout.Controls.OfType<Control>().Where(ct => ct.Name == "btOK").FirstOrDefault() == null)
            {
                //得到空的空间
                EmptySpaceItem a = layout.Items.Where(it => it.TypeName == "EmptySpaceItem").FirstOrDefault() as EmptySpaceItem;

                //得到取消按钮，重写点击事件
                Control clearBtn = layout.Controls.OfType<Control>().Where(ct => ct.Name == "btClear").FirstOrDefault();
                LayoutControlItem clearLCI = (LayoutControlItem)layout.GetItemByControl(clearBtn);
                clearBtn.Click += clearBtn制作工艺_Click;

                //添加一个simplebutton控件(确认按钮)
                LayoutControlItem myLCI = (LayoutControlItem)clearLCI.Owner.CreateLayoutItem(clearLCI.Parent);
                myLCI.TextVisible = false;
            }
        }
        /// <summary>
        /// 点击选择后的行为
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void searchLookUpEdit制作工艺View_Click(object sender, EventArgs e)
        {
            var a = this.searchLookUpEdit制作工艺.Properties.View.GetSelectedRows();
            foreach (int rowHandle in a)
            {
                this.制作工艺 = this.searchLookUpEdit制作工艺.Properties.View.GetRowCellValue(rowHandle, "Name").ToString();
                this.model.Dto定制下单.STYLE_MAKE_TYPE = this.searchLookUpEdit制作工艺.Properties.View.GetRowCellValue(rowHandle, "ID").ToString();
            }
            //this.mianliaoid.Text = this.dto无订单打印.materials_id;
            //this.mianliaocd.Text = this.dto无订单打印.materials_cd;
            //this.chengfen.Text = this.dto无订单打印.materialComposition;
        }

        /// <summary>
        /// 清除按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void clearBtn制作工艺_Click(object sender, EventArgs e)
        {
            this.searchLookUpEdit制作工艺.ToolTip = null;
            searchLookUpEdit制作工艺.EditValue = null;
        }
        /// <summary>
        /// 选完之后的显示
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void searchLookUpEdit制作工艺_CustomDisplayText(object sender, DevExpress.XtraEditors.Controls.CustomDisplayTextEventArgs e)
        {
            if (null != e.Value)
                e.DisplayText = this.制作工艺;
        }
        #endregion


        private void barEditItemNumber_EditValueChanged(object sender, EventArgs e)
        {
            //this.model.Dto定制下单.build数量(this.barEditItem数量.EditValue.ToString());
        }
        private void gridViewSize_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            this.model.buildCountSize(e.RowHandle, e.Column.FieldName, e.Value.ToString());    //  尺寸计算

            this.gridControlSize.DataSource = this.model.尺寸呈现;
            this.gridControlSize.Refresh();
        }
        private void gridViewSize_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            //e.Appearance.BackColor = Color.NavajoWhite;
            if (e.Column.Name == "colGarment")
            {
                if (this.model.尺寸呈现[e.RowHandle].OUT_VALUE > this.model.尺寸呈现[e.RowHandle].leastReasonable)
                {
                    //该行数据的该列的值不为空时时,其背景色为Red
                    e.Appearance.BackColor = Color.Red;//设置单元格变色
                                                       //e.Column.AppearanceCell.BackColor = Color.Red;//设置数据列变色
                }
                else if (this.model.尺寸呈现[e.RowHandle].IN_VALUE > this.model.尺寸呈现[e.RowHandle].maxReasonable)
                {
                    //该行数据的该列的值不为空时时,其背景色为Red
                    e.Appearance.BackColor = Color.Green;//设置单元格变色
                                                         //e.Column.AppearanceCell.BackColor = Color.Red;//设置数据列变色
                }
                else
                {
                    e.Appearance.BackColor = Color.CornflowerBlue;
                }
            }
        }
        private void chicun01_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                //  选中尺码：
                foreach (SizeFitKashiyamaDTO item in this.sizeFitKashiyamaDTOS)
                {
                    if (this.chicun01.Text.Trim().Equals(item.sizeCdShort))
                    {
                        this.model.Dto定制下单.STYLE_SIZE_CD = item.sizeCd;
                        break;
                    }
                }
                //  尺码对应尺寸表：
                List<SizeKashiyamaResultDTO> sizeKashiyamaResultDTOs =
                    款式Service.getSizeKashiyamaResult(
                        this.model.Dto定制下单.STYLE_FIT_CD,
                        this.model.Dto定制下单.STYLE_SIZE_CD,
                        this.model.Dto定制下单.STYLE_SIZE_GROUP_CD,
                        this.model.Dto定制下单.Style_Id
                        );
                List<尺寸呈现dto> 尺寸呈现 = new List<尺寸呈现dto>();
                foreach (SizeKashiyamaResultDTO item in sizeKashiyamaResultDTOs)
                {
                    尺寸呈现.Add(new 尺寸呈现dto(item).CountSize());
                }
                this.model.尺寸呈现 = 尺寸呈现;
                this.gridControlSize.DataSource = this.model.尺寸呈现;
            }
            catch (Exception ex)
            {
                MessageBox.Show("尺寸表为空");
                return;
            }
            //this.model.build选中尺寸(this.chicun01.Text.Trim(), this.model.Dto定制下单.Style_Id, Frm定制下单修改尺寸.stylesizedt);
            //this.model.Dto定制下单.STYLE_SIZE_CD = SizeService.SizeCD(this.chicun01.Text.Trim(), Frm定制下单修改尺寸.stylesizedt);
            //this.model.尺寸呈现 = SizeService.GetThisSize(this.model.Dto定制下单);
            //foreach (尺寸呈现dto dto in this.model.尺寸呈现)
            //{
            //    dto.CountSize();
            //}
            //this.gridControlSize.DataSource = this.model.尺寸呈现;
        }
        private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("确认保存吗？", "保存", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (dialogResult == DialogResult.Yes)
            {
                this.model.Dto定制下单.build数量(this.numericUpDown数量.Value.ToString());
                //this.model.Dto定制下单.ORDER_NUMBER = Convert.ToInt32(this.barEditItemNumber.EditValue);

                //ImpService.DynamicSaveSize(this, this.model.Dto定制下单);//尺寸保存
                this.model.build尺寸保存();//尺寸保存
                String str = FunctionHelper.JsonSerialization(this.model.Dto定制下单.Dto尺寸);
                //ImpService.DynamicSaveDesign(this, this.model.Dto定制下单);//设计点保存
                try
                {
                    //  校验订单
                    this.model.verify订单();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
                
                this.frm.buildKashiyamaOrderModel(this.model.Dto定制下单, this.model.尺寸呈现);
                this.frm.refreshGridControl();
                //this.addPics();

                MessageBox.Show("保存成功");
                this.Close();
            }
        }


        private void numericUpDown数量_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (((NumericUpDown)sender).Text.Trim().IndexOf('.') > -1)
            {
                if (((NumericUpDown)sender).Text.Trim().Substring(((NumericUpDown)sender).Text.Trim().IndexOf('.') + 1).Length >= 0)//定义小数位
                {
                    if (!char.IsDigit(e.KeyChar))
                    {
                        e.Handled = false;
                    }
                    else
                    {
                        e.Handled = true;
                    }
                }
            }
        }

        private void richTextBox备注_TextChanged(object sender, EventArgs e)
        {
            this.model.build备注(this.richTextBox备注.Text);
        }
        /// <summary>
        /// 初始化导航
        /// </summary>
        /// <param name="uC"></param>
        private void initNavigationPage(XtraUserControl uC)
        {
            uC.Dock = DockStyle.Fill;
            this.dockPanel设计点.Controls.Clear();
            this.dockPanel设计点.Controls.Add(uC);
        }
    }
}
